package com.huohuzhihui.web.controller.api;

import com.huohuzhihui.common.core.controller.BaseController;
import com.huohuzhihui.common.core.domain.AjaxResult;
import com.huohuzhihui.common.core.domain.entity.SysDept;
import com.huohuzhihui.common.core.domain.entity.SysUser;
import com.huohuzhihui.common.core.domain.model.LoginUser;
import com.huohuzhihui.common.utils.StringUtils;
import com.huohuzhihui.framework.web.service.TokenService;
import com.huohuzhihui.merchant.domain.Goods;
import com.huohuzhihui.merchant.service.IGoodsService;
import com.huohuzhihui.merchant.service.IOrderService;
import com.huohuzhihui.system.service.ISysDeptService;
import com.ijpay.core.kit.IpKit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 微信api
 *
 * @author lizhihe
 * @date 2020-11-22
 */
@RestController
@RequestMapping("/api/goods")
public class ApiGoodsController extends BaseController {
    @Autowired
    private IGoodsService goodsService;
    @Autowired
    private TokenService tokenService;
    @Autowired
    private ISysDeptService deptService;


    /**
     * 商户查找所属代理商的套餐
     *
     * @param request
     * @return
     */
    @PostMapping("/findGoodsList")
    public AjaxResult findGoodsList(HttpServletRequest request) {

        Goods goods = new Goods();
        /*LoginUser loginUser = tokenService.getLoginUser(request);
        SysUser sysUser = loginUser.getUser();
        SysDept dept = deptService.selectDeptById(sysUser.getDeptId());
        goods.setAgentId(dept.getParentId());*/

        List<Goods> goodsList = goodsService.selectGoodsList(goods);
        return new AjaxResult(200, "获取代理套餐成功", goodsList);
    }


}
